//
//  HJHNavigationController.swift
//  WeiBoPro
//
//  Created by nadyboy on 2018/4/26.
//  Copyright © 2018年 hjh. All rights reserved.
//

import UIKit

class HJHNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
     //隐藏系统的bar
      navigationBar.isHidden = true
        // Do any additional setup after loading the view.
    }
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
        //返回按钮，第一级显示上一层的title，其他的都为返回
        if  let  vc = viewController as? HJHBaseViewController{
            var title = "返回"
            if childViewControllers.count == 1
                {
                 title = childViewControllers.first?.title ?? "返回 "
                }
            vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popVc),isBack:true)
            }
        }
        super.pushViewController(viewController, animated: animated)
    }
    //返回上一层
    @objc func popVc()
    {
        popViewController(animated: true)
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
